package com.skyolder.crutch.ast;

import com.skyolder.crutch.error.GrammarError;
import com.skyolder.crutch.error.RunError;
import com.skyolder.crutch.ev.Environment;
import com.skyolder.crutch.word.TokenQueue;
import com.skyolder.crutch.word.token.StringToken;
import com.skyolder.crutch.word.token.SymbolToken;
import com.skyolder.crutch.word.token.Token;
import com.skyolder.crutch.word.types.SymbolType;

public class NameSpaceTree implements Tree {
	Environment parentEnvironment = null;
	TokenQueue tokenQueue = null;
	Environment functionEnvironment = null;
	String namepsace=null;
	public NameSpaceTree(Environment environment, TokenQueue tokenQueue) {
		parentEnvironment = environment;
		this.tokenQueue = tokenQueue;
		functionEnvironment = new Environment(parentEnvironment);
	}

	@Override
	public void excute() throws RunError {

	}

	@Override
	public void build() throws GrammarError {
		tokenQueue.nextToken();
		Token tk = tokenQueue.nextToken();
		if (!(tk instanceof StringToken)) {
			throw new GrammarError(tk.toString());
		}
		Token tkk=tokenQueue.nextToken();
		if(!(tkk instanceof SymbolToken)){
			throw new GrammarError(tkk.toString());
		}
		SymbolToken tkkk=(SymbolToken)tkk;
		if(tkkk.getSymbolType()!=SymbolType.SEMICOLON){
			throw new GrammarError(tkkk.toString());
		}
		namepsace=((StringToken)tk).getValue();
		
	}
	public String getNameSpace(){
		return namepsace;
	}
}
